package com.hzdp.jvm;

/**
 * VM Args：-Xss2M （这时候不妨设置大些）  
 * 
 */
public class JavaVMStackOOM {

	private void dontStop() {
		while (true)
			;
	}

	public void stackLeakByThread() {
		while (true) {
			Thread thread = new Thread(new Runnable() {
				public void run() {
					dontStop();
				}
			});
			thread.start();
		}
	}

	public static void main(String[] args) throws Exception {
		JavaVMStackOOM javaVMStackOSF = new JavaVMStackOOM();
		try {
			javaVMStackOSF.stackLeakByThread();
		} catch (Exception e) {
			Thread.sleep(2000);
			throw e;
		}
	}
}
